package cn.iocoder.yudao.module.wms.dal.mysql.saleorder;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.wms.dal.dataobject.saleorder.SaleDetailDO;
import cn.iocoder.yudao.module.wms.dal.dataobject.saleorder.SaleOrderDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wms.controller.admin.saleorder.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 销售订单主 Mapper
 *
 * @author wait
 */
@Mapper
public interface SaleOrderMapper extends BaseMapperX<SaleOrderDO> {

    default PageResult<SaleOrderDO> selectPage(SaleOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SaleOrderDO>()
                .eqIfPresent(SaleOrderDO::getSerialNumber, reqVO.getSerialNumber())
                .eqIfPresent(SaleOrderDO::getPersonId, reqVO.getPersonId())
                .eqIfPresent(SaleOrderDO::getCustomerId, reqVO.getCustomerId())
                .betweenIfPresent(SaleOrderDO::getOrderDate, reqVO.getOrderDate())
                .eqIfPresent(SaleOrderDO::getStatus, reqVO.getStatus())
                .orderByDesc(SaleOrderDO::getId));
    }

    void updateSaleOrderStatus(SaleOrderSaveReqVO saleOrderSaveReqVO);
    SaleOrderDO findByProcessInstanceId(String processInstanceId);
    List<SaleOrderDO> findSaleOrderOperateList();
    List<SaleDetialRespVO> findSaleDetialByPid(Integer pid);
    SaleDetialRespVO findSaleDetialById(Integer id);
    void updateSaleDetial(SaleDetialRespVO saleDetailDO);
    List<SaleDetialRespVO> findSaleDetialOperateList(Integer pid);
    SaleDetialRespVO findSaleDetialByInventoryIdAndPid(@Param("inventoryId")Integer inventoryId,@Param("pid")Integer pid);
}